package com.bamboocloud.im.service;


import com.bamboocloud.im.entity.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Auther xuwen
 * @Date 2021/12/13 15:03
 * @Version 1.0
 */
//降级~
@Component
public class DeptClientServiceFallbackFactory implements FallbackFactory {
    @Override
    public DeptClientService create(Throwable throwable) {
        return new DeptClientService() {
            @Override
            public boolean add(Dept dept) {
                return false;
            }

            @Override
            public Dept get(Long id) {
                return new Dept()
                        .setDeptno(id)
                        .setDname("id=>"+id+"没有对应的信息，客户端提供了降级的信息，这个服务现在已经关闭了")
                        .setDb_source("没有数据");

            }

            @Override
            public List<Dept> gets() {
                return null;
            }
        };
    }
}
